<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<table class="form-table">
	<tr>
		<td colspan="4">
			<div class="header">
				<h3>分类信息</h3>
			</div></td>
	</tr>
	<tr>
		<td class="td1">分类：</td>
		<td class="td2"><form:hidden path="icdCategoryId" /> <isperp:treeSelector
				width="500" displayColumn="name" displayValueCssStyle="width:249px"
				url="incident/category/getTree"
				autocompleteUrl="incident/category/list"
				afterSelectEmpty="clearicdCategory();" id="icdCategorySelector"
				name="icdCategoryName" displayValue="${model.icdCategoryName }"
				afterSelected="changeIcdCategory(treeNode.id,false);"
				valueControlId="icdCategoryId" displayValueCssClass="required"></isperp:treeSelector>
		</td>

		<td class="td1">紧急度：</td>
		<td class="td2">${model.urgencyName }</td>
	</tr>
	<tr id="supporter_tr1line">
		 
		<td class="td1">影响度：</td>
		<td class="td2">${model.effectName }</td>
	</tr>
	<tr id="supporter_tr2line">
		<td class="td1">支持人员：</td>
		<td class="td2">${model.supporterName}</td>

		<td class="td1">优先级：</td>
		<td class="td2">${model.priorityName }&nbsp;&nbsp;<label style="color:#ff6600">(一级最高，四级最低)</label></td>
	</tr>
</table>

<script type="text/javascript">
	function changeIsBear(v) {

		if (v == 1) {
			$("#confirmtimemanId").val($("#applicationBearId").val());
			$("#confirmtimemanName").val($("#applicationBearName").val());
		} else {
			$("#confirmtimemanId").val($("#basisBearId").val());
			$("#confirmtimemanName").val($("#basisBearName").val());
		}
	}
	//选择事件分类带出二线担当 

	function clearicdCategory() {
		$("#icdCategorySelector").val("");
		$("#icdCategoryId").val("");
		$("#icdCategoryName").val("");
		$("#confirmtimemanId").val("");
		$("#confirmtimemanName").val("");
	}

	function changeIcdCategory(id, clearData) {
		if (id) {
			searchCategoryDandang(id, clearData);
		}

		if (clearData) {
			$("#confirmtimemanId").val("");
			$("#confirmtimemanName").val("");
		}
	}

	function searchCategoryDandang(categoryId, clearData) {
		$.getJSON("incident/categoryRelamembers/findRelaAppUserByCategoryIdAndRole?categoryId=" + categoryId, function(data) {
			
			if (data[0]) {
				$(data).each(function(index, item) {
					$("#applicationBearId").val(item.application_bear_id);
					$("#applicationBearName").val(item.application_bear_name);
					$("#basisBearId").val(item.basis_bear_id);
					$("#basisBearName").val(item.basis_bear_name);

					var bearType = "${model.bearType}";
					if (bearType == "")
						bearType = 1;
					
					if (clearData){
						$("#bearType_" + bearType).click();
						changeIsBear(bearType);
					}else{
						$("#bearType_" + bearType).attr("checked",true);
					}
				});
			}
		});
	}

	function getAddressByLoactionDiv(cellValue, rowObject) {
		if (rowObject.longitude && rowObject.latitude && rowObject.longitude != "" && rowObject.latitude != "") {
			var location = (rowObject.latitude + "") + "," + (rowObject.longitude + "");
			return "<div class='location_div' style='white-space:pre-wrap' id='row_"+rowObject.id+"' data-id='"+rowObject.id+"' data-location='"+location+"'>加载中...</div>";
		}
		return "";
	}

	function getAddressByLoaction() {

	}

	$(document).ready(function() {
		changeIcdCategory("${model.icdCategoryId}", false);

	});
</script>